#include "../mqserver/mq_queue.hpp"

#include <gtest/gtest.h>

mq::MsgQueueManager::ptr mqp;
class MsgQueueTest : public testing::Environment
{
     virtual void SetUp() override
    {
        mqp = std::make_shared<mq::MsgQueueManager>("./data/queue.db");
    }

    virtual void TearDown() override
    {
        // mqp->clear();
    }
};

TEST(msgqueue_test,insert_test)
{
    // std::unordered_map<std::string,std::string> map = {{"k1","v1"}};
    // mqp->declareQueue("queue1",1,0,0,map);
    // mqp->declareQueue("queue2",1,0,0,map);
    // mqp->declareQueue("queue3",1,0,0,map);
    ASSERT_EQ(mqp->size(),3);
    ASSERT_EQ(mqp->exists("queue1"),true);
    ASSERT_EQ(mqp->exists("queue2"),true);
    ASSERT_EQ(mqp->exists("queue3"),true);
}

// TEST(msgqueue_test,select_test)
// {
//     mq::MsgQueue::ptr mp = mqp->selectQueue("queue3");
//     ASSERT_NE(mp.get(), nullptr);
//     ASSERT_EQ(mp->name, "queue3");
//     ASSERT_EQ(mp->durable, true);
//     ASSERT_EQ(mp->exclusive, false);
//     ASSERT_EQ(mp->auto_delete, false);
//     ASSERT_EQ(mp->getArgs(), std::string("k1=v1&"));
// }

// TEST(queue_test, remove_test) {
//     mqp->deleteQueue("queue3");
//     ASSERT_EQ(mqp->exists("queue3"), false);
// }

int main(int args,char *argv[])
{
    testing::AddGlobalTestEnvironment(new MsgQueueTest);
    testing::InitGoogleTest(&args,argv);
    RUN_ALL_TESTS();
    return 0;
}